<?php
	/**
	This file is part of PEL.
		PEL is free software: you can redistribute it and/or modify
		it under the terms of the GNU General Public License as published by
		the Free Software Foundation, either version 3 of the License, or
		(at your option) any later version.
	    
		PEL is distributed in the hope that it will be useful,
		but WITHOUT ANY WARRANTY; without even the implied warranty of
		MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
		GNU General Public License for more details.
	    
		You should have received a copy of the GNU General Public License
		along with PEL.  If not, see <http://www.gnu.org/licenses/>.
	* Elgg pel index page
	*/

	// Load Elgg engine
	require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php");
		
	// Get the current page's owner
	$page_owner = page_owner_entity();

	if ($page_owner === false || is_null($page_owner)){
		$page_owner = $_SESSION['user'];
		set_page_owner($_SESSION['guid']);
	}
	//set pel title
	if($page_owner == $_SESSION['user']){
		$area2 = elgg_view_title(elgg_echo('pel:your'));
		if(get_user_objects($page_owner->getGUID(),'pel',10)){
        // Get a list of langs
      $area2 .= elgg_view("pel/list");
		}
		else{
			$area2 .= elgg_view("pel/forms/edit");
		}
	}
  else{

    $area2 = elgg_view_title(elgg_echo('pel:friends'));
    $area2 .=elgg_view("pel/listfriends", array('owner'=>$page_owner));
  }
	
	// Display them in the page
	$body = elgg_view_layout("two_column_left_sidebar", '', $area1 . $area2);
		
	// Display page
	page_draw(sprintf(elgg_echo('pel:user'),$page_owner->name),$body);
?>
